<template>
  <div class="wrapper">
    <split-pane split="horizontal" :default-percent="60" v-on:resize="resize">
      <template slot="paneL">
        <div class="top-type" ref="topType">
          <div class="form">
            <el-form ref="form" :model="form" :rules="rule" :inline="true" size="mini">
              <el-form-item prop="orderNum" label="订单号:">
                <el-input placeholder="请输入" v-model="form.orderNum" style="width: 180px" clearable></el-input>
              </el-form-item>
              <el-form-item prop="orderStatue" label="订单状态:">
                <!-- <el-input v-model="form.orderStatue" clearable></el-input> -->
                <el-select clearable v-model="form.orderStatue" style="width: 180px">
                  <el-option v-for="(item, index) in statusList" :key="index" :value="item.rvLowValue" :label="item.rvCmeaning"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="合同编号：" prop="contractNo">
                <el-input clearable v-model="form.contractNo" style="width: 180px" placeholder="请输入"></el-input>
              </el-form-item>
              <el-form-item prop="start" label="下单时间:">
                <el-date-picker placeholder="请选择" v-model="form.start" style="width: 180px" value-format="yyyy-MM-dd"></el-date-picker>
                -
                <el-date-picker placeholder="请选择" v-model="form.end" style="width: 180px" value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
              <!-- <el-form-item prop="start" label="下单时间:">
                  <el-date-picker
                    v-model="form.start"
                    style="width:180px"
                    value-format="yyyy-MM-dd"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item prop="end" label-width="3em" label="——">
                  <el-date-picker
                    v-model="form.end"
                    style="width:180px"
                    value-format="yyyy-MM-dd"
                  ></el-date-picker>
              </el-form-item>-->
              <el-form-item>
                <el-button type="primary" size="mini" @click="searchList">查 询</el-button>
              </el-form-item>
            </el-form>
          </div>
          <!--          <div class="btn">-->
          <!--            <el-button plain size="mini" type="primary" v-if="isAuth('dispatchCar')" @click="dispatchOrder">指派订单</el-button>-->
          <!--          </div>-->
          <div class="name">订单信息列表</div>
          <el-table
            :data="tableData"
            border
            class="dispatching"
            :height="typeHeight"
            :header-cell-style="{ textAlign: 'center' }"
            highlight-current-row
            @row-click="rowClick"
            @row-dblclick="dbrowClick"
          >
            <el-table-column :index="indexMethod" type="index" align="center" label=" " width="50"></el-table-column>
            <el-table-column align="center" prop="attStatusName" label="订单状态" show-overflow-tooltip width="180"></el-table-column>
            <el-table-column align="center" prop="cmtContractNo" label="合同号" show-overflow-tooltip width="180"></el-table-column>
            <el-table-column align="left" prop="attCode" label="订单号" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="adcConsigner" label="客户名称" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="adcSAddress" label="起始地" show-overflow-tooltip width="200"></el-table-column>
            <el-table-column align="left" prop="adcDAddress" label="目的地" show-overflow-tooltip width="200"></el-table-column>
            <el-table-column align="left" prop="gdsNames" label="货物名称" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="dispatchedWeight" label="已派车量" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="gdsSurplusWeight" label="未派车量" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="left" prop="attAuditor" label="审核人" show-overflow-tooltip width="160"></el-table-column>
            <el-table-column align="center" prop="attAudittime" label="审核时间" show-overflow-tooltip width="180"></el-table-column>
            <el-table-column align="left" prop="attRemark" label="备注" show-overflow-tooltip width="180"></el-table-column>
            <!--            <el-table-column   align="center" prop="attCreatetime"  label="下单时间" show-overflow-tooltip  width="180"></el-table-column>-->
            <!--            <el-table-column   align="left" prop="adcLinkperson"  label="联系人" show-overflow-tooltip  width="160"></el-table-column>-->
            <!--            <el-table-column   align="left" prop="adcLinkphone"  label="联系电话" show-overflow-tooltip  width="160"></el-table-column>-->
            <!--              <el-table-column   align="right" prop="gdsWeight"  label="订单总质量(T)" show-overflow-tooltip  width="160"></el-table-column>-->
            <!--              <el-table-column   align="right" prop="rmbamount"  label="订单金额(RMB)" show-overflow-tooltip  width="160"></el-table-column>-->
            <!--              <el-table-column   align="left" prop="attAuditdiffering"  label="审核拒绝原因" show-overflow-tooltip  width="180"></el-table-column>-->
          </el-table>
          <div>
            <el-pagination
              ref="pagination"
              small
              background
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="Pagination.currentPage"
              :page-sizes="Pagination.pageSizeList"
              :page-size="Pagination.pageSize"
              :layout="Pagination.layout"
              :total="Pagination.total"
            ></el-pagination>
          </div>
        </div>
      </template>
      <template slot="paneR">
        <div class="bottom-code" ref="bottomCode">
          <div class="bottomBtn">
            <el-button plain size="mini" type="primary" @click="dispatchOrder">派车</el-button>
            <el-button plain size="mini" type="primary" @click="editDispatcher">编辑</el-button>
            <el-button plain size="mini" type="primary" @click="undoWayBill">撤销</el-button>
          </div>
          <div class="name">运单信息列表</div>
          <el-table
            :data="topTableData"
            border
            :height="detlHeight"
            :header-cell-style="{ textAlign: 'center' }"
            highlight-current-row
            @row-click="getTopCurrent"
          >
            <el-table-column type="index" align="center" label=" " width="50"></el-table-column>
            <el-table-column prop="waContractNo" label="合同号" width="200" show-overflow-tooltip sortable></el-table-column>
            <!-- <el-table-column prop="attCode" label="订单号" width="200" show-overflow-tooltip sortable></el-table-column> -->
            <el-table-column prop="wabCode" label="运单号" width="200" show-overflow-tooltip sortable>
              <template slot-scope="scope">
                <div style="color: #409eff" @click="JumpMonitor">{{ scope.row.wabCode }}</div>
              </template>
              <!-- <template slot-scope="scope">-->
              <!--                <u  @click="getWaybillDynamics(scope.row.wabCode)">{{scope.row.wabCode}}</u>-->
              <!--              </template> -->
            </el-table-column>
            <el-table-column prop="trkNo" label="车牌号" width="110" show-overflow-tooltip></el-table-column>
            <el-table-column prop="dvrName" label="司机" show-overflow-tooltip></el-table-column>
            <el-table-column prop="dvrCtctel" label="司机电话" width="150" align="left" show-overflow-tooltip></el-table-column>
            <!--            <el-table-column prop="wabStatus" label="运单状态" width="110" align="center" show-overflow-tooltip sortable ></el-table-column>-->
            <el-table-column prop="wabStatusName" label="运单状态" width="110" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="wabGoodname" label="货物名称" width="110" show-overflow-tooltip></el-table-column>
            <el-table-column prop="wabWeight" label="货物重量(T)" width="130" align="right" show-overflow-tooltip></el-table-column>
            <!--            <el-table-column prop="WAB_ETC" label="ETC费用" width="110" align="right" show-overflow-tooltip sortable ></el-table-column>-->
            <!--            <el-table-column prop="WAB_OILCONS" label="油耗费用" width="110" align="right" show-overflow-tooltip sortable ></el-table-column>-->
            <!--            <el-table-column prop="WAB_POERF" label="运费" align="right" show-overflow-tooltip sortable ></el-table-column>-->
            <!--            <el-table-column prop="RESUL" label="总和" align="right" show-overflow-tooltip sortable ></el-table-column>-->
            <el-table-column prop="wcdSttime" label="装货时间" width="110" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="wcdEdtime" label="卸货时间" width="110" align="center" show-overflow-tooltip></el-table-column>
            <!--            <el-table-column prop="tayOprtdate" label="轨迹跟踪" width="110" show-overflow-tooltip sortable ></el-table-column>-->
            <!--            <el-table-column prop="auditStatus" label="审核标识" width="110" show-overflow-tooltip sortable ></el-table-column>-->
            <!--            <el-table-column prop="tayOprtdate" label="审核操作人" width="120" show-overflow-tooltip sortable ></el-table-column>-->
            <!--            <el-table-column prop="tayOprtdate" label="审核操作时间" width="130" align="center" show-overflow-tooltip sortable ></el-table-column>-->
            <el-table-column prop="tayOprtdate" label="备注" show-overflow-tooltip></el-table-column>
          </el-table>
        </div>
      </template>
    </split-pane>

    <!-- 对话框 新增 编辑司机 -->
    <el-dialog :title="nameSJ" :visible.sync="openDialogSJ" v-if="openDialogSJ" v-el-drag-dialog :before-close="SJclose" :close-on-click-modal="false">
      <el-form :model="dialogForm" size="mini" :rules="dialogRule" ref="dialogForm" label-width="auto">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="dvrName" label="司机姓名：">
              <el-input v-model="dialogForm.dvrName" style="width: 95%" maxlength="15" clearable :disabled="seeSJ"> </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="dvrCtctel" label="手机号码：">
              <el-input v-model="dialogForm.dvrCtctel" maxlength="11" style="width: 95%" clearable :disabled="seeSJ"> </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="dvrLicense" label="驾驶证编号：">
              <el-input v-model="dialogForm.dvrLicense" maxlength="12" style="width: 95%" clearable :disabled="seeSJ"> </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="dvrVehicleclass" label="准驾车型：">
              <el-select v-model="dialogForm.dvrVehicleclass" style="width: 95%" clearable :disabled="seeSJ">
                <el-option v-for="(item, index) in carType" :key="index" :value="item.rvLowValue" :label="item.rvCmeaning"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="dvrIssuingOrg" label="驾驶证发证机关：">
              <el-input v-model="dialogForm.dvrIssuingOrg" style="width: 95%" maxlength="32" clearable :disabled="seeSJ"> </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="dvrQualiyCer" label="从业资格证号：">
              <el-input v-model="dialogForm.dvrQualiyCer" style="width: 95%" maxlength="15" clearable :disabled="seeSJ"> </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="dvrValidpfrom" label="驾驶证有效期开始：">
              <el-date-picker
                v-model="dialogForm.dvrValidpfrom"
                style="width: 95%"
                @change="startTimeChange"
                clearable
                :disabled="seeSJ"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="dvrValidpto" label="驾驶证有效期结束：">
              <el-date-picker v-model="dialogForm.dvrValidpto" style="width: 95%" @change="endTimeChange" clearable :disabled="seeSJ" value-format="yyyy-MM-dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="dvrNtvpalce" label="籍贯：	">
              <el-input v-model="dialogForm.dvrNtvpalce" style="width: 95%" maxlength="32" clearable :disabled="seeSJ"> </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="dvrIdcard" label="身份证号码：">
              <el-input v-model="dialogForm.dvrIdcard" style="width: 95%" maxlength="18" clearable :disabled="seeSJ"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="dvrHvqlfcation" label="重大件资质：">
              <el-radio-group v-model="dialogForm.dvrHvqlfcation" :disabled="seeSJ">
                <el-radio label="Y">是</el-radio>
                <el-radio label="N">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="dvrDgsqlfcation" label="危险品资质：">
              <el-radio-group v-model="dialogForm.dvrDgsqlfcation" :disabled="seeSJ">
                <el-radio label="Y">是</el-radio>
                <el-radio label="N">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24">
          <el-form-item prop="dvrHaddress" label="家庭住址：">
            <el-col :span="24">
              <el-input v-model="dialogForm.dvrHaddress" style="width: 98%" clearable maxlength="32" :disabled="seeSJ"></el-input>
            </el-col>
          </el-form-item>
        </el-row>
        <el-row :gutter="24">
          <el-form-item prop="dvrPermanent" label="常驻地址：">
            <el-col :span="24">
              <el-input v-model="dialogForm.dvrPermanent" style="width: 98%" clearable maxlength="32" :disabled="seeSJ"></el-input>
            </el-col>
          </el-form-item>
        </el-row>
        <el-row :gutter="24">
          <el-form-item prop="dvrRemark" label="备注：">
            <el-col :span="24">
              <el-input type="textarea" v-model="dialogForm.dvrRemark" :rows="2" maxlength="200" :disabled="seeSJ" style="width: 98%"></el-input>
            </el-col>
          </el-form-item>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="5" style="margin-left: 150px">
            <div class="step2-upload">
              <el-upload
                action=""
                :data="{ step: 'two', code: 'sfzz' }"
                :http-request="uploadImageA"
                :before-upload="beforeUploadA"
                :show-file-list="false"
                class="avatar-uploader"
              >
                <img v-if="imageUrl.two" :src="imgUrl.two1" class="avatar" />
                <i v-else class="el-icon-plus uploader-icon"></i>
              </el-upload>
              <p>上传身份证正面(必填)</p>
            </div>
          </el-col>
          <el-col :span="5">
            <div class="step2-upload">
              <el-upload
                action=""
                :data="{ step: 'three', code: 'sfzb' }"
                :http-request="uploadImageA"
                :before-upload="beforeUploadA"
                :show-file-list="false"
                class="avatar-uploader"
              >
                <img v-if="imageUrl.three" :src="imgUrl.three1" class="avatar" />
                <i v-else class="el-icon-plus uploader-icon"></i>
              </el-upload>
              <p>上传身份证反面(必填)</p>
            </div>
          </el-col>
          <el-col :span="5">
            <div class="step2-upload">
              <el-upload
                action=""
                :data="{ step: 'four', code: 'jsz' }"
                :http-request="uploadImageA"
                :before-upload="beforeUploadA"
                :show-file-list="false"
                class="avatar-uploader"
              >
                <img v-if="imageUrl.four" :src="imgUrl.four1" class="avatar" />
                <i v-else class="el-icon-plus uploader-icon"></i>
              </el-upload>
              <p>上传驾驶证</p>
            </div>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 10px">
        <el-button @click="SJclose" size="mini">关闭</el-button>
        <el-button type="primary" @click="saveSJ" v-if="!seeSJ" size="mini">保存</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="name" width="80%" :visible.sync="openDialog" v-if="openDialog" v-el-drag-dialog :before-close="close" :close-on-click-modal="false">
      <div class="content"></div>
      <div class="box" v-if="!see">
        <div class="name">车辆信息</div>
        <!--           <el-form :model="basicForm" size="mini" :rules="TruckRule" ref="basicForm">-->
        <div class="form2">
          <el-form ref="form2" :model="form2" :rules="rule2" label-width="auto" :inline="true" size="mini">
            <el-form-item prop="trkNo" label="车牌号：">
              <el-input v-model="form2.trkNo" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" size="mini" @click="getCars">查 询</el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="addbutton">
          <el-button type="primary" size="mini" @click="addDriver" v-if="!edit">新增司机</el-button>
          <el-button type="primary" size="mini" @click="addCar" v-if="!edit">新增车辆</el-button>
        </div>
        <!--        highlight-current-row-->
        <el-table
          :data="carInfo"
          border
          height="380px"
          @current-change="changeCurrentCar"
          @row-click="carRowClick"
          @select="selectClick"
          @select-all="selectClickAll"
          @selection-change="handleSelectionChange"
          :row-style="rowClass"
          ref="multipleTable"
          :header-cell-style="{ textAlign: 'center' }"
          :cell-style="cellStyleHandler"
        >
          <!--               <el-table-column prop="valid" align="center"  label="序号" width="50">-->
          <!--                 <template slot-scope="scope">-->
          <!--                   <el-checkbox disabled v-model="scope.row.valid" true-label="Y" false-label="N"></el-checkbox>-->
          <!--                 </template>-->
          <!--               </el-table-column>-->
          <!--              <el-table-column disabled='true' align="center" type="selection" width="55"  :selectable='checkboxT'></el-table-column>-->
          <el-table-column align="center" type="selection" width="55"></el-table-column>
          <!--               <el-table-column  align="center" prop="zx" label="在线" show-overflow-tooltip width="120"></el-table-column>-->

          <el-table-column align="left" prop="cph" v-if="!edit" label="车牌号" show-overflow-tooltip width=""></el-table-column>
          <el-table-column align="left" prop="cph" v-if="edit" label="车牌号" show-overflow-tooltip width="">
            <template slot-scope="scope">
              <el-select clearable v-model="scope.row.cph" :disabled="!edit" @change="changeTrkNo">
                <el-option v-for="(item, index) in trkNos" :key="index" :label="item.trkNo" :value="item.uuid"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <!--               <el-table-column  align="left" prop="cx" label="车型" show-overflow-tooltip width=""></el-table-column>-->
          <el-table-column align="right" prop="wabCtrNo" label="箱号" show-overflow-tooltip width="">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.wabCtrNo"
                @input="changewabCtrNo"
                :disabled="edit"
                @paste.native="onPaste(scope, $event)"
                maxLength="30"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column align="right" prop="wabSealNo" label="铅封号" show-overflow-tooltip width="">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.wabSealNo"
                @input="changewabSealNo"
                :disabled="edit"
                @paste.native="onPaste(scope, $event)"
                maxLength="30"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column align="right" prop="wabProBatch" label="生产批次" show-overflow-tooltip width="">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.wabProBatch"
                @input="changewabProBatch"
                :disabled="edit"
                @paste.native="onPaste(scope, $event)"
                maxLength="30"
              ></el-input>
            </template>
            <!--                 <template slot-scope="scope">-->
            <!--                     <el-date-picker-->
            <!--                       v-model="scope.row.wabProBatch"-->
            <!--                       value-format="yyyy-MM-dd"-->
            <!--                       @input="changewabProBatch"-->
            <!--                       :disabled="edit"-->
            <!--                     >-->
            <!--                     </el-date-picker>-->
            <!--                 </template>-->
          </el-table-column>
          <el-table-column align="right" prop="trkTonnage" label="载重吨(T)" show-overflow-tooltip width=""></el-table-column>
          <el-table-column align="right" prop="terminalNo" label="设备号" show-overflow-tooltip width=""></el-table-column>
          <el-table-column align="right" prop="wcdDwt" label="托运量(T)" show-overflow-tooltip width="">
            <template slot-scope="scope">
              <el-input clearable v-model="scope.row.wcdDwt" @input="changeDwt" @paste.native="onPaste(scope, $event)"></el-input>
            </template>
          </el-table-column>
          <el-table-column align="left" prop="sj" label="司机" show-overflow-tooltip width="">
            <template slot-scope="scope">
              <el-select @change="changeA(scope.row)" v-model="scope.row.sj" size="mini" :disabled="scope.row.isSelect">
                <el-option v-for="(item, index) in driver" :key="index" :value="item.uuid" :label="item.dvrName"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column align="left" prop="lxdh" label="联系电话" show-overflow-tooltip width=""></el-table-column>
          <!--               <el-table-column  align="center" prop="sxsj" label="上线时间" show-overflow-tooltip width=""></el-table-column>-->
          <!--               <el-table-column  align="center" prop="zt" label="状态" show-overflow-tooltip width="130"></el-table-column>-->
        </el-table>
        <!--           </el-form>-->
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close" size="mini">关闭</el-button>
        <el-button type="primary" @click="save" v-if="!edit" size="mini">派车</el-button>
        <el-button type="primary" @click="saveTrk" v-if="edit" size="mini">保存</el-button>
      </div>
    </el-dialog>

    <!-- 对话框 新增 编辑车辆 -->
    <el-dialog
      width="700px"
      :title="nameCL"
      :visible.sync="openDialogCL"
      v-if="openDialogCL"
      v-el-drag-dialog
      :before-close="CLclose"
      :close-on-click-modal="false"
    >
      <el-form :model="dialogFormCL" size="mini" :rules="dialogRuleCL" ref="dialogFormCL" label-width="auto">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="trkNo" label="车牌号：">
              <el-input v-model="dialogFormCL.trkNo" style="width: 95%" clearable :disabled="seeCL" maxlength="32"> </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="trkDriverUuid" label="司机姓名：">
              <el-select v-model="dialogFormCL.trkDriverUuid" style="width: 95%" clearable :disabled="seeCL" filterable>
                <el-option v-for="(item, index) in driver" :key="index" :value="item.uuid" :label="item.dvrName"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="trkConductor" label="车长：">
              <el-select v-model="dialogFormCL.trkConductor" style="width: 95%" clearable :disabled="seeCL" filterable>
                <el-option v-for="(item, index) in carLong" :key="index" :value="item.rvLowValue" :label="item.rvCmeaning"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="trkType" label="车型：">
              <el-select v-model="dialogFormCL.trkType" style="width: 95%" clearable :disabled="seeCL" filterable>
                <el-option v-for="(item, index) in carType" :key="index" :value="item.rvLowValue" :label="item.rvCmeaning"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="trkOwner" label="所有人：">
              <el-input v-model="dialogFormCL.trkOwner" style="width: 95%" maxlength="32" clearable :disabled="seeCL"> </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="trkGrossmass" label="总质量(t)：">
              <el-input v-model="dialogFormCL.trkGrossmass" style="width: 95%" maxlength="32" clearable :disabled="seeCL"> </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="trkTonnage" label="载重吨：">
              <el-input v-model="dialogFormCL.trkTonnage" style="width: 95%" maxlength="32" clearable :disabled="seeCL"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="trkColorcode" label="车牌颜色代码：">
              <el-select v-model="dialogFormCL.trkColorcode" style="width: 95%" clearable :disabled="seeCL">
                <el-option v-for="(item, index) in carColor" :key="index" :value="item.rvLowValue" :label="item.rvCmeaning"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="trkUsercharacter" label="使用性质：">
              <el-input v-model="dialogFormCL.trkUsercharacter" style="width: 95%" maxlength="32" clearable :disabled="seeCL"> </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="trkVin" label="车辆识别代码：	">
              <el-input v-model="dialogFormCL.trkVin" style="width: 95%" maxlength="27" clearable :disabled="seeCL"> </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="trkIssuingorg" label="发证机关：">
              <el-input v-model="dialogFormCL.trkIssuingorg" style="width: 95%" maxlength="32" clearable :disabled="seeCL"> </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="trkRegisterdate" label="注册日期：">
              <el-date-picker
                v-model="dialogFormCL.trkRegisterdate"
                style="width: 95%"
                @change="startTimeChange"
                clearable
                :disabled="seeCL"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="trkIssuedate" label="发证日期：">
              <el-date-picker
                v-model="dialogFormCL.trkIssuedate"
                style="width: 95%"
                clearable
                @change="endTimeChange"
                :disabled="seeCL"
                value-format="yyyy-MM-dd"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="trkEnergytype" label="车辆能源类型：">
              <el-input v-model="dialogFormCL.trkEnergytype" style="width: 95%" clearable :disabled="seeCL" maxlength="16"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="trkAxlenumber" label="车辆轴数：">
              <el-select v-model="dialogFormCL.trkAxlenumber" style="width: 95%" clearable :disabled="seeCL" filterable>
                <el-option v-for="(item, index) in carAxel" :key="index" :value="item.rvLowValue" :label="item.rvCmeaning"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="trkVlflag" label="使用否">
              <el-radio-group v-model="dialogFormCL.trkVlflag" :disabled="seeCL" style="width: 95%">
                <el-radio label="Y">是</el-radio>
                <el-radio label="N">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-form-item prop="trkRtcn" label="道路运输证号：">
            <el-col :span="24">
              <el-input v-model="dialogFormCL.trkRtcn" style="width: 98%" clearable :disabled="seeCL" maxlength="14"></el-input>
            </el-col>
          </el-form-item>
        </el-row>
        <el-row :gutter="24">
          <el-form-item prop="trkEnginenumber" label="发动机号：">
            <el-col :span="24">
              <el-input v-model="dialogFormCL.trkEnginenumber" style="width: 98%" clearable :disabled="seeCL" maxlength="32"></el-input>
            </el-col>
          </el-form-item>
        </el-row>
        <el-row :gutter="24">
          <el-form-item prop="trkTvpn" label="挂车牌照号：">
            <el-col :span="24">
              <el-input v-model="dialogFormCL.trkTvpn" :rows="2" style="width: 98%" :disabled="seeCL" maxlength="32"></el-input>
            </el-col>
          </el-form-item>
        </el-row>
        <el-row :gutter="24">
          <el-form-item prop="terminalNo" label="设备号：">
            <el-col :span="24">
              <el-input v-model="dialogFormCL.terminalNo" :rows="2" style="width: 98%" :disabled="seeCL" maxlength="32"></el-input>
            </el-col>
          </el-form-item>
        </el-row>

        <el-row :gutter="24">
          <el-form-item prop="trkRemark" label="备注：">
            <el-col :span="24">
              <el-input type="textarea" v-model="dialogFormCL.trkRemark" :rows="2" style="width: 98%" maxlength="200" :disabled="seeCL"></el-input>
            </el-col>
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="CLclose" size="mini">关闭</el-button>
        <el-button type="primary" @click="saveCL" v-if="!seeCL" size="mini">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import paginationMixin from '@/mixins/pagination'
import resizeMixin from '@/mixins/resize'
import isAuth from '@/mixins/buttonAuth'
import concateForm from '../threeOrderSupervise/concate'
import { accAdd, accSub, getNowTime } from '@/utils/utils'
import {
  addAllTmAttendancecar,
  getDriverModelList,
  getRefCodesByType,
  getTmAttendanceList,
  getVehicleModelList,
  orderInfo,
  undoWayBill,
  uploadDriverImg,
  UploadFile,
  addDriverModelList,
  addVehicleModel,
} from '@/request/api'
import { editWayBillTrkNoSer, sendOrderList } from '@/request/internal/sendorder'
import { sumArr } from '@/utils/aboutArray'
import { getWillBillListByAttCode } from '@/request/orderSupervise/orderPlan'
import scrollChange from '@/utils/onscroll'
import store from '@/store'
// import { sendOrder } from '../../../request/internal/sendorder'

export default {
  name: 'router.Dispatching',
  mixins: [paginationMixin, resizeMixin, isAuth],
  components: { concateForm },
  data() {
    return {
      carInfoData: {
        cph: '',
        sj: '',
        lxdh: '',
        wcdDwt: '',
        trkTonnage: '',
        gdsWeight: '', //总重量
        wabCtrNo: '',
        wabSealNo: '',
        wabProBatch: '',
      },

      carLong: [], //车长
      carAxel: [], //车轴
      driver: [], //司机
      carColor: [], //车辆颜色
      nameCL: '',
      openDialogCL: false,
      dialogFormCL: {},
      dialogRuleCL: {
        trkNo: [{ required: true, message: '请输入车牌号', trigger: 'blur' }],
        trkDriverUuid: [{ required: true, message: '请选择司机', trigger: 'blur' }],
        trkTonnage: [
          { required: true, message: '请输入载重吨', trigger: 'blur' },
          {
            pattern: /^\d+$|^(\d+)(\.\d+)?$/,
            message: '请输入阿拉伯数字',
            trigger: 'blur',
          },
        ],
      },
      seeCL: false, //查看模式
      nameSJ: '',
      seeSJ: false, //查看模式
      imageUrl: {
        one: '', // 头像 url
        two: '', // 身份证正面 url
        three: '', // 身份证反面 url
        four: '', // 驾驶证 url
      },
      openDialogSJ: false,
      dialogForm: {},
      dialogRule: {
        //验证规则
        dvrName: [{ required: true, message: '请输入司机姓名', trigger: 'blur' }],
        dvrCtctel: [{ required: true, pattern: /^\d{11}$/, message: '请输入11位手机号', trigger: 'blur' }],
        dvrIdcard: [
          { required: true, message: '请输入18位身份证号码', trigger: 'blur' },
          {
            pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
            message: '请输入18位身份证号码',
            trigger: 'blur',
          },
        ],
      },
      lxrphone: '',
      selectRow: [], //checkbox当前选中行
      selectData: [], //checkbox选中的数据
      isSelect: true,
      curData: [],
      drvTel: '',
      form: {
        orderNum: '',
        orderStatue: '',
        orderTime: '',
        contractNo: '', // 合同编号
      },
      form2: {
        trkNo: '',
      },
      rule: {
        orderNum: [],
        orderStatue: [],
        orderTime: [],
      },
      rule2: {
        trkNo: [],
      },
      nowDay: '',
      statusList: [], //状态值
      maxHeight: -1,
      typeHeight: -1, ////上方表格高度
      detlHeight: -1, //下方表格高度
      tableData: [],
      topTableData: [], //运单信息列表数据
      botTableData: [], //运单信息动态列表数据（无用）
      topCurrentData: [], //运单信息当前行数据
      currentData: null, //单击选中数据
      carRowClickData: {}, //单击选中数据
      viewData: {}, //双击选中数据

      //对话框----新增修改
      name: '指派订单',
      openDialog: false,
      edit: false, //编辑
      see: false, //查看
      check: true, //审核
      customer: [], //客户
      carType: [], //车型
      payer: [], //卸车支付
      payWay: [], //结算方式
      payTime: [], //结算方式
      carLong: [], //车长
      trkNo: '', //车辆
      trkNos: [], //车辆信息
      trkNoAndW: [], //车牌号和重量
      distanceForm: {}, //里程信息
      sumGdsWeight: {}, //剩余货物重量总和
      surplusGdsWeight: '', //派完此单剩余货物重量总量
      totalGdsQuantity: {}, //总件数
      trkTonnage: {}, //车辆核载重量
      wcdDwt: '', //托运量
      wabCtrNo: '', //箱号
      wabSealNo: '', //铅封号
      wabProBatch: '', //生产批次
      sj: '', //司机
      distanceRule: {
        distance: [{ required: true, message: '请输入里程', trigger: 'blur' }],
        time: [{ required: true, message: '请输入时间', trigger: 'blur' }],
      },
      basicForm: {}, //基础信息
      basicRule: {
        khmc: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
        wtr: [{ required: true, message: '请输入委托人', trigger: 'blur' }],
        lxr: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
        lxdh: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
        sj: [{ required: true, message: '请输入司机名称', trigger: 'blur' }],
        email: [{ required: true, message: '请输入Email地址', trigger: 'blur' }],
        qq: [{ required: false, message: '请输入QQ', trigger: 'blur' }],
        wx: [{ required: false, message: '请输入微信', trigger: 'blur' }],
        khtqzysj: [{ required: true, message: '请输入客户要求作业时间', trigger: 'blur' }],
        khyqzywcsj: [
          {
            required: true,
            message: '请输入客户要求作业完成时间',
            trigger: 'blur',
          },
        ],
        cxyq: [{ required: true, message: '请输入车型要求', trigger: 'blur' }],
        xcfzff: [{ required: true, message: '请输入卸车支付方', trigger: 'blur' }],
        ddjsfs: [{ required: true, message: '请输入订单结算方式', trigger: 'blur' }],
        ccyq: [{ required: true, message: '请输入车长要求', trigger: 'blur' }],
      },
      sendForm: {}, //发货信息
      acceptForm: {}, //收货信息
      concateRule: {},
      goodsForm: [
        {
          hwlx: 'mc',
          hm: '货名',
          js: '件数',
          zl: '重量',
          tj: '体积',
          dw: '单位',
          bz: '备注',
        },
      ], //货物信息
      TruckRule: {
        wabCtrNo: [{ required: true, message: '请输入箱号', trigger: 'blur' }],
        wabSealNo: [{ required: true, message: '请输入铅封号', trigger: 'blur' }],
        wabProBatch: [{ required: true, message: '请选择生产批次', trigger: 'blur' }],
        wcdDwt: [
          { required: true, message: '请输入运输量', trigger: 'blur' },
          {
            pattern: /^[0-9]+$/,
            message: '只能输入数字',
            trigger: 'change',
          },
        ],
      },
      huhu: {},
      //车辆信息
      carInfo: [],
      view: '1',
      typeId: [],
      driver: [], //司机
    }
  },
  mounted() {
    //车型
    getRefCodesByType('车型_网络').then(res => {
      if (res.success === '1') {
        this.carType = res.data
      }
    })
    //车长
    getRefCodesByType('车长_网络').then(res => {
      if (res.success === '1') {
        this.carLong = res.data
      }
    })
    //车轴
    getRefCodesByType('车辆轴数').then(res => {
      if (res.success === '1') {
        this.carAxel = res.data
      }
    })
    //车辆颜色
    getRefCodesByType('车辆颜色').then(res => {
      if (res.success === '1') {
        this.carColor = res.data
      }
    })
    let demandWrapper = document.querySelector('.dispatching .el-table__body-wrapper')
    // 新增滚动条监听事件
    scrollChange(demandWrapper)
  },
  created() {
    this.resize = () => {
      this.typeHeight = this.$refs.topType.offsetHeight - 120
      this.detlHeight = this.$refs.bottomCode.offsetHeight - 80
    }
    //订单状态
    getRefCodesByType('网络平台订单状态').then(res => {
      if (res.success === '1') {
        this.statusList = res.data
      }
    })
    getVehicleModelList({ trkNo: '' }).then(response => {
      this.trkNos = response.data
      this.trkNos.forEach(f => {
        this.$set(this.trkNoAndW, f.trkNo, f.trkTonnage)
      })
    })
    getDriverModelList({
      dvrName: '',
      PageIndexs: '',
      PageSizes: '',
    }).then(res => {
      if (res.success === '1') {
        this.driver = res.data
      }
      //   res.data.forEach(item =>{
      //   this.huhu[item.uuid] = item.dvrName
      // })
    })
    this.refreshList()
    this.getdatatime()
    this.allFa()
  },
  watch: {
    selectData(data) {
      this.selectRow = []
      if (data.length > 0) {
        data.forEach((item, index) => {
          this.selectRow.push(this.carInfo.indexOf(item))
        })
      }
    },
    basicForm: {
      handler() {
        this.getPay(this.basicForm.adcJsfh)
      },
    },
  },
  computed: {
    // 上传预览图片 由于后台返回的地址是相对地址 需要转换为绝对地址
    imgUrl() {
      return {
        one1: api.IMAGE_PREFIX + this.imageUrl.one,
        two1: api.IMAGE_PREFIX + this.imageUrl.two,
        three1: api.IMAGE_PREFIX + this.imageUrl.three,
        four1: api.IMAGE_PREFIX + this.imageUrl.four,
      }
    },
  },
  methods: {
    saveCL() {
      this.$refs.dialogFormCL.validate(valid => {
        if (valid) {
          //新增
          addVehicleModel(this.dialogFormCL).then(res => {
            if (res.success === '1') {
              this.$message({
                type: 'success',
                message: '新增数据成功！',
                showClose: true,
              })
              this.allFa().then(() => this.CLclose())
            }
          })
        }
      })
    },
    addCar() {
      this.openDialogCL = true
      this.seeCL = false
      this.nameCL = '新增车辆信息'
      this.dialogFormCL = {
        trkNo: '',
        trkDriverUuid: '',
        trkConductor: '',
        trkType: '',
        trkOwner: '',
        trkGrossmass: '',
        trkTonnage: '',
        trkColorcode: '',
        trkUsercharacter: '',
        trkVin: '',
        trkIssuingorg: '',
        trkRegisterdate: '',
        trkIssuedate: '',
        trkEnergytype: '',
        trkAxlenumber: '',
        trkRtcn: '',
        trkEnginenumber: '',
        trkTvpn: '',
        trkVlflag: 'Y',
        bz: '',
      }
    },
    startTimeChange() {
      let vbsStartime
      let vbsEndtime
      vbsStartime = new Date(Date.parse(this.dialogForm.dvrValidpfrom))
      vbsEndtime = new Date(Date.parse(this.dialogForm.dvrValidpto))
      if (vbsStartime > vbsEndtime) {
        this.dialogForm.dvrValidpfrom = ''
        this.$message.error({
          showClose: true,
          message: '驾驶证有效期开始时间不能大于驾驶证有效期结束时间！',
          type: 'warning',
          duration: 8000,
        })
      }
    },
    endTimeChange() {
      let vbsStartime
      let vbsEndtime
      vbsStartime = new Date(Date.parse(this.dialogForm.dvrValidpfrom))
      vbsEndtime = new Date(Date.parse(this.dialogForm.dvrValidpto))
      if (vbsStartime > vbsEndtime) {
        this.dialogForm.dvrValidpto = ''
        this.$message.error({
          showClose: true,
          message: '驾驶证有效期结束时间不能小于驾驶证有效期开始时间！',
          type: 'warning',
          duration: 8000,
        })
      }
    },
    // 图片上传之前的检查
    beforeUploadA(file) {
      if (file.type.indexOf('image') === -1) {
        this.$message.error({
          message: '请上传正确的图片类型',
          showClose: true,
        })
        return false
      }

      if (file.size / 1024 / 1024 > this.size) {
        this.$message.warning({
          message: '建议文件大小在 ' + this.size + ' M以内',
          showClose: true,
        })
        return false
      }
    },
    // 上传图片
    uploadImageA({ data, file }) {
      this.issuse = data.code
      uploadDriverImg(file, this.issuse, this.currentData.uuid).then(res => {
        if (res.success == '1') {
          this.$message({
            message: '图片上传成功！',
            type: 'success',
          })
          this.imageUrl[data.step] = res.msg
        }
      })
    },
    addDriver() {
      this.openDialogSJ = true
      this.seeSJ = false
      this.nameSJ = '新增司机信息'
      this.dialogForm = {
        dvrName: '',
        dvrCtctel: '',
        dvrLicense: '',
        dvrVehicleclass: '',
        dvrIssuingOrg: '',
        dvrQualiyCer: '',
        dvrValidpfrom: '',
        dvrValidpto: '',
        dvrPayway: '',
        dvrReceiptacco: '',
        dvrNtvpalce: '',
        dvrBankcode: '',
        dvrHvqlfcation: 'N',
        dvrDgsqlfcation: 'N',
        dvrIdcard: '',
        dvrHaddress: '',
        dvrPermanent: '',
        dvrRemark: '',
        dvrLicenurl: '', //驾驶
        dvrSfzpositive: '', //身份证
        dvrSfzreverse: '',
        isaudit: 'N', //审核
      }
    },
    JumpMonitor() {
      this.$router.push('/layout/capacityManage/twoCapacityManage/capacityMonitor')
    },
    getDriverModelList() {
      //司机
      getDriverModelList({
        dvrName: '',
        PageIndexs: '',
        PageSizes: '',
      }).then(res => {
        if (res.success === '1') {
          this.driver = res.data
        }
        //   res.data.forEach(item =>{
        //   this.huhu[item.uuid] = item.dvrName
        // })
      })
    },
    changeA(row) {
      this.sj = row.sj
      this.driver.forEach(item => {
        if (item.uuid == row.sj) {
          row.lxdh = item.dvrCtctel
        }
      })
    },
    saveSJ() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          this.dialogForm.dvrHead = this.imageUrl.one
          this.dialogForm.dvrSfzpositive = this.imageUrl.two
          this.dialogForm.dvrSfzreverse = this.imageUrl.three
          this.dialogForm.dvrLicenurl = this.imageUrl.four

          //新增
          // let  box = Object.assign(this.dialogForm,{})
          addDriverModelList(this.dialogForm).then(res => {
            if (res.success === '1') {
              this.$message({
                type: 'success',
                message: '新增数据成功',
                showClose: true,
              })
              this.SJclose()
            }
          })
        }
      })
    },
    save() {
      // const car = this.carInfo.find(item => item.valid !== 'N')
      // if (!car) {
      //   this.$alert('请选择指派车辆！','提示',{
      //     confirmButtonText:'确定'
      //   })
      //   return
      // }

      if (Object.keys(this.selectData).length == 0) {
        this.$alert('请选择指派车辆！', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      if (this.wcdDwt == 0 || this.wcdDwt == '') {
        this.$alert('请输入托运量！', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      if (this.sj == null || this.sj == '') {
        this.$alert('请先补录该车辆运力发布司机信息', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      this.surplusGdsWeight = parseFloat(this.sumGdsWeight)
      const list = []
      this.selectData
        .filter(item => item.wcdDwt)
        .forEach(item => {
          this.surplusGdsWeight = accSub(this.surplusGdsWeight, item.wcdDwt)
          if (this.surplusGdsWeight < 0) {
            this.$message.error({
              showClose: true,
              message: '指派吨数超过订单总吨数',
            })
            return
          }
          list.push({
            attUuid: this.currentData.uuid,
            wdcId: item.uuid,
            trkDvrUuid: item.sj, //司机id
            surplusGdsWeight: this.surplusGdsWeight, //派完此单剩余货物重量总量
            sumGdsWeight: this.sumGdsWeight, //货物总重量
            trkTonnage: item.trkTonnage, //车辆核载量
            wcdDwt: item.wcdDwt, //托运量
            wabCtrNo: item.wabCtrNo, //箱号
            wabSealNo: item.wabSealNo, //铅封号
            wabProBatch: item.wabProBatch, //生产批次
            totalGdsQuantity: item.totalGdsQuantity, //总件数
            fltUuid: store.state.user.FLT_UUID_DX_H,
            attLstmodifier: store.state.user.USR_CODE_DX_H,
            modifer: store.state.user.USR_CODE_DX_H,
          })
        })
      sendOrderList({ list }).then(() => {
        this.$message.success('指派车辆成功！')
        this.openDialog = false
        this.currentData = null
        this.carInfo = []
        this.isSelect = true
        this.selectRow = []
        this.refreshList()
      })
      // this.selectData.forEach((s, index) => {
      //   this.surplusGdsWeight = accSub(this.surplusGdsWeight, s.wcdDwt)
      //   sendOrder({
      //     uuid: this.currentData.uuid,
      //     wdcId: s.uuid,
      //     trkDvrUuid: s.sj, //司机id
      //     surplusGdsWeight: this.surplusGdsWeight, //派完此单剩余货物重量总量
      //     sumGdsWeight: this.sumGdsWeight, //货物总重量
      //     trkTonnage: s.trkTonnage, //车辆核载量
      //     wcdDwt: s.wcdDwt, //托运量
      //     wabCtrNo: s.wabCtrNo, //箱号
      //     wabSealNo: s.wabSealNo, //铅封号
      //     wabProBatch: s.wabProBatch, //生产批次
      //     totalGdsQuantity: s.totalGdsQuantity //总件数
      //   }).then(() => {
      //     if (index == this.selectData.length - 1) {
      //       this.$message.success('指派车辆成功！')
      //       this.openDialog = false
      //       this.currentData = null
      //       this.isSelect = true
      //       this.selectRow = []
      //       this.refreshList()
      //     }
      //   })
      // })

      // sendOrder({
      //   uuid: this.currentData.uuid,
      //   wdcId: car.uuid,
      //   surplusGdsWeight: this.surplusGdsWeight,
      //   sumGdsWeight: this.sumGdsWeight, //货物总重量
      //   trkTonnage: this.trkTonnage,     //车辆核载量
      //   wcdDwt: this.wcdDwt,             //托运量
      //   wabCtrNo: this.wabCtrNo,         //箱号
      //   wabSealNo: this.wabSealNo,       //铅封号
      //   wabProBatch: this.wabProBatch,   //生产批次
      //   totalGdsQuantity: this.totalGdsQuantity //总件数
      // }).then(() => {
      //   this.$message.success('指派车辆成功！')
      //   this.openDialog = false
      //   this.currentData = null
      //   this.refreshList()
      // })
    },
    saveTrk() {
      editWayBillTrkNoSer({
        attUuid: this.topCurrentData.attUuid,
        uuid: this.topCurrentData.uuid,
        trkId: this.trkNo,
        driver: this.sj,
        wabWeight: this.wcdDwt,
      }).then(() => {
        this.$message.success('编辑成功！')
        this.openDialog = false
        this.edit = false
        this.currentData = null
        this.topTableData = null
        this.refreshList()
      })
    },
    //重写getList
    getList(currentPage, pageSize, updateTotal) {
      orderInfo({
        attCode: this.form.orderNum,
        attStatus: this.form.orderStatue,
        attCreatetimeStart: this.form.start,
        attCreatetimeEnd: this.form.end,
        PageIndex: this.Pagination.currentPage,
        PageSize: this.Pagination.pageSize,
        cmtContractNo: this.form.contractNo,
      }).then(response => {
        this.tableData = response.data
        updateTotal(Number(response.total))
        this.tableData.forEach(s => {
          s.gdsNames = ''
          s.goodsForm.map(m => {
            s.gdsNames += m.gdsName + ','
          })
        })
      })
      this.currentData = null
    },
    //获取结算类型
    getPay(name) {
      // this.basicForm.adcJsfhValue=''
      this.payTime = []
      getRefCodesByType(name).then(res => {
        if (res.success === '1') {
          this.payTime = res.data
        }
      })
    },
    changeCurrentCar(currentRow, oldCurrentRow) {
      // currentRow.valid = 'Y'
      // currentRow.valid = currentRow.valid == 'Y' ? 'N' : 'Y'
      // oldCurrentRow && (oldCurrentRow.valid = 'N')
    },
    // 选中筛选结果时候
    handleSelectionChange(data) {
      this.selectData = data
    },
    // 多选高亮选中行
    rowClass({ row, rowIndex }) {
      if (this.selectRow.includes(rowIndex)) {
        return { 'background-color': 'rgba(87, 134, 238, 0.75)' }
      }
    },
    //将chexbox置为disabled方法
    checkboxT(row, index) {
      if (row.status == 0) {
        return 1
      } else {
        return 0
      }
    },
    selectClick(rows, row) {
      let selected = rows.length && rows.indexOf(row) !== -1
      if (selected == true) {
        row.isSelect = false
      } else if (selected == 0 || false) {
        row.isSelect = true
      }
    },
    selectClickAll(data) {
      this.carInfo.forEach(item => {
        if (data.length == this.carInfo.length) {
          item.isSelect = false
        } else {
          item.isSelect = true
        }
      })
    },
    carRowClick(row) {
      // if (this.selectData.includes(row)) {
      //   this.$refs.multipleTable.toggleRowSelection(row, false) // 清空当前行选择
      // } else {
      //   this.$refs.multipleTable.toggleRowSelection(row) //  选中当前选择
      // }
      // this.isSelect = false
      this.curData = row
      this.$refs.multipleTable.toggleRowSelection(row, true) //  选中当前选择
      row.valid = row.valid == 'Y' ? 'N' : 'Y'
      this.carRowClickData = row
      if (row.sj == null) {
        this.sj = ''
        this.$alert('请先补录该车辆运力发布司机信息', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      this.carInfo.forEach(e => {
        e.flag = false
      })
      let gdsWeightSum = this.basicForm.goodsForm.map(goods => parseFloat(goods.gdsSurplusWeight))
      let sum = sumArr(gdsWeightSum)
      this.sumGdsWeight = sum
      // let gdsQuantitysum = this.basicForm.goodsForm.map(goods => parseFloat(goods.gdsQuantity))
      // let sum1 = sumArr(gdsQuantitysum)
      // this.totalGdsQuantity = sum1
      this.trkTonnage = row.trkTonnage
      this.wcdDwt = row.wcdDwt
      this.wabCtrNo = row.wabCtrNo
      this.wabSealNo = row.wabSealNo
      this.wabProBatch = row.wabProBatch
      this.sj = row.sj
      row.flag = true
    },
    rowClick(row) {
      this.currentData = Object.assign({}, row)
      this.basicForm = this.currentData
      setTimeout(() => {
        this.getWab()
      }, 200)
    },
    getWab() {
      getWillBillListByAttCode({
        orderCode: this.currentData.attCode,
        isPlatform: 'N',
      }).then(res => {
        this.topTableData = res.data
      })
    },
    dbrowClick(row) {
      this.currentData = Object.assign({}, row)
      this.basicForm = this.currentData
      //收货
      this.acceptForm = {
        orReveivingparty: this.currentData.orReveivingparty,
        lxr: this.currentData.orReveivingpartycontacts,
        lxdh: this.currentData.orReveivingpartytel,
        adcDSfinwrkdate: this.currentData.adcDSfinwrkdate,
        adcDEfinwrkdate: this.currentData.adcDEfinwrkdate,
        province: this.currentData.odcDProvince,
        city: this.currentData.orReveivingpartytelcity,
        district: this.currentData.odcDArea,
        xxdz: this.currentData.adcDAddress,
        jd: this.currentData.adcDX,
        wd: this.currentData.adcDY,
      }
      //发货
      this.sendForm = {
        orShipper: this.currentData.orShipper,
        lxr: this.currentData.orShippercontacts,
        lxdh: this.currentData.orShippertel,
        adcSSwrkdate: this.currentData.adcSSwrkdate,
        adcSEwrkdate: this.currentData.adcSEwrkdate,
        province: this.currentData.odcSProvince,
        city: this.currentData.orDeliverypointcity,
        district: this.currentData.odcSArea,
        xxdz: this.currentData.adcSAddress,
        jd: this.currentData.adcSX,
        wd: this.currentData.adcSY,
      }
      this.distanceForm = this.currentData
      this.goodsForm[0] = this.currentData
      this.auditForm = {}
      this.see = true
      this.name = '查看订单'
      this.openDialog = true
    },
    //改变箱号时触发
    changewabCtrNo(wabCtrNo) {
      this.wabCtrNo = wabCtrNo
      this.carInfo
        .filter(f => f.uuid == this.carRowClickData.uuid)
        .map(m => {
          m.wabCtrNo = wabCtrNo
        })
      this.selectData
        .filter(f => f.uuid == this.carRowClickData.uuid)
        .map(m => {
          m.wabCtrNo = wabCtrNo
        })
    },
    //改变铅封号时触发
    changewabSealNo(wabSealNo) {
      this.wabSealNo = wabSealNo
      this.carInfo
        .filter(f => f.uuid == this.carRowClickData.uuid)
        .map(m => {
          m.wabSealNo = wabSealNo
        })
      this.selectData
        .filter(f => f.uuid == this.carRowClickData.uuid)
        .map(m => {
          m.wabSealNo = wabSealNo
        })
    },
    //改变生产批次时触发
    changewabProBatch(wabProBatch) {
      this.wabProBatch = wabProBatch
      this.carInfo
        .filter(f => f.uuid == this.carRowClickData.uuid)
        .map(m => {
          m.wabProBatch = wabProBatch
        })
      this.selectData
        .filter(f => f.uuid == this.carRowClickData.uuid)
        .map(m => {
          m.wabProBatch = wabProBatch
        })
    },
    changeDwt(wcdDwt) {
      let countAllDwt = ''
      this.selectData.forEach(s => (countAllDwt = accAdd(countAllDwt, s.wcdDwt)))
      if (parseFloat(countAllDwt) - parseFloat(this.topCurrentData.wabWeight) > parseFloat(this.sumGdsWeight)) {
        this.carInfo.forEach(car => {
          if (car.uuid == this.carRowClickData.uuid) {
            car.wcdDwt = ''
          }
        })
        // this.carInfo.filter(f => f.uuid == this.carRowClickData.uuid).map(m => {
        //   m.wcdDwt = ''
        // })
        this.$alert('您输入的托运量总和超过订单货物剩余总重量，请重新新输入', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      this.carInfo
        .filter(f => f.uuid == this.carRowClickData.uuid)
        .map(m => {
          m.wcdDwt = wcdDwt
        })
      this.selectData
        .filter(f => f.uuid == this.carRowClickData.uuid)
        .map(m => {
          m.wcdDwt = wcdDwt
        })
      this.wcdDwt = wcdDwt
      if (parseFloat(wcdDwt) > parseFloat(this.trkTonnage)) {
        // this.carInfo.forEach(car => {
        //   if (car.uuid == this.carRowClickData.uuid) {
        //     car.wcdDwt = ''
        //   }
        // })
        this.$alert('您输入的托运量超过车辆载重吨，请根据实际情况运输', '提示', {
          confirmButtonText: '确定',
        })
        return
      } else if (parseFloat(wcdDwt) > parseFloat(this.topCurrentData.wabWeight) + parseFloat(this.sumGdsWeight)) {
        this.carInfo.forEach(car => {
          if (car.uuid == this.carRowClickData.uuid) {
            car.wcdDwt = ''
          }
        })
        this.$alert('您输入的托运量超过订单货物剩余总重量，请重新新输入', '提示', {
          confirmButtonText: '确定',
        })
        return
      } else if (parseFloat(wcdDwt) < 0) {
        this.carInfo.forEach(car => {
          if (car.wcdDwt == wcdDwt) {
            car.wcdDwt = ''
          }
        })
        this.$alert('托运量不可为负数，请重新新输入', '提示', {
          confirmButtonText: '确定',
        })
        return
      } else if (wcdDwt == false) {
        this.$alert('请输入正确的托运量', '提示')
      } else {
        this.surplusGdsWeight = parseFloat(this.sumGdsWeight) - parseFloat(wcdDwt)
        return false
      }
    },
    //关闭对话框
    close() {
      this.openDialogCL = false
      this.imageUrl.one = ''
      this.imageUrl.two = ''
      this.imageUrl.three = ''
      this.imageUrl.four = ''
      this.openDialogSJ = false
      this.openDialog = false
      this.currentData = null
      this.see = false
      this.edit = false
      this.isSelect = true
      this.carInfo = []
      this.selectRow = []
      this.refreshList()
    },
    SJclose() {
      this.openDialogSJ = false
      this.getDriverModelList()
      this.dialogForm = {}
    },
    CLclose() {
      this.openDialogCL = false
      this.getCars()
      this.dialogFormCL = {}
    },
    formmate(str) {
      const date = new Date(str)
      const year = date.getFullYear()
      const month = date.getMonth() + 1
      const day = date.getDate()
      return `${year}-${month}-${day}`
    },
    getdatatime() {
      //默认显示今天

      // this.date=`${year}-${month}-${day}`
      var time = new Date()
      this.nowDay = this.formmate(time)
    },
    allFa() {
      return addAllTmAttendancecar({ wdcTime: this.nowDay })
    },
    //派单
    dispatchOrder() {
      if (!this.currentData || Object.keys(this.currentData).length === 0) {
        this.$alert('每次只能指派一行数据，你已选择0行', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      if (!['YSH', 'BFPC'].includes(this.currentData.attStatus)) {
        this.$alert('已审核或者部分派车的订单才能指派,此订单不能指派！', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      //收货
      this.acceptForm = {
        orReveivingparty: this.currentData.orReveivingparty,
        lxr: this.currentData.orReveivingpartycontacts,
        lxdh: this.currentData.orReveivingpartytel,
        adcDSfinwrkdate: this.currentData.adcDSfinwrkdate,
        adcDEfinwrkdate: this.currentData.adcDEfinwrkdate,
        province: this.currentData.odcDProvince,
        city: this.currentData.orReveivingpartytelcity,
        district: this.currentData.odcDArea,
        xxdz: this.currentData.adcDAddress,
        jd: this.currentData.adcDX,
        wd: this.currentData.adcDY,
      }
      //发货
      this.sendForm = {
        orShipper: this.currentData.orShipper,
        lxr: this.currentData.orShippercontacts,
        lxdh: this.currentData.orShippertel,
        adcSSwrkdate: this.currentData.adcSSwrkdate,
        adcSEwrkdate: this.currentData.adcSEwrkdate,
        province: this.currentData.odcSProvince,
        city: this.currentData.orDeliverypointcity,
        district: this.currentData.odcSArea,
        xxdz: this.currentData.adcSAddress,
        jd: this.currentData.adcSX,
        wd: this.currentData.adcSY,
      }
      this.distanceForm = this.currentData
      this.goodsForm[0] = this.currentData
      // this.carInfo[0] = this.
      this.auditForm = {}
      this.see = false
      this.name = '指派订单'
      this.getCars()
      this.getDriverModelList()
      this.openDialog = true
    },
    editDispatcher() {
      if (!this.topCurrentData || Object.keys(this.topCurrentData).length === 0) {
        this.$alert('每次只能编辑一行数据，你已选择0行', '提示', {
          confirmButtonText: '确定',
        })
        return
      }

      // if (this.topCurrentData.wabStatus != 'PC') {
      //   this.$alert('已接单的运单不可修改', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      this.see = false
      this.edit = true
      this.name = '编辑'
      // let  lxrphone =''
      // for (let index = 0; index < this.driver.length; index++) {
      //   if(this.driver[index].dvrName ===this.topCurrentData.dvrName){
      //     lxrphone=this.driver[index].dvrCtctel
      //   }
      // }
      this.openDialog = true
      this.carInfo = []
      this.carInfoData = {
        cph: this.topCurrentData.trkNo,
        sj: String(this.topCurrentData.dvrUuid),
        lxdh: this.topCurrentData.dvrCtctel,
        wcdDwt: this.topCurrentData.wabWeight,
        trkTonnage: this.trkNoAndW[this.topCurrentData.trkNo],
        gdsWeight: this.sumGdsWeight, //总重量
        wabCtrNo: this.topCurrentData.wabCtrNo,
        wabSealNo: this.topCurrentData.wabSealNo,
        wabProBatch: this.topCurrentData.wabProBatch,
      }
      this.carInfo.push(this.carInfoData)
      // this.carInfo[0] = {
      //   cph: this.topCurrentData.trkNo,
      //   sj: this.topCurrentData.dvrName,
      //   lxdh: this.topCurrentData.dvrCtctel,
      //   wcdDwt: this.topCurrentData.wabWeight,
      //   trkTonnage: this.trkNoAndW[this.topCurrentData.trkNo],
      //   gdsWeight: this.sumGdsWeight, //总重量
      //   wabCtrNo: this.topCurrentData.wabCtrNo,
      //   wabSealNo: this.topCurrentData.wabSealNo,
      //   wabProBatch: this.topCurrentData.wabProBatch
      // }
    },
    //改变箱号时触发
    changeTrkNo(cph) {
      this.trkNo = cph
    },
    getCars() {
      getTmAttendanceList({
        wdcTime: getNowTime().split(' ')[0],
        trkNo: this.form2.trkNo,
        wdcIsuse: 'N',
      }).then(res => {
        this.carInfo = res.data.map(item => {
          return {
            uuid: item.wdcId,
            valid: 'N',
            zx: item.wdcStatus === 'Y' ? '在线' : '不在线',
            cph: item.trkNo,
            cx: item.formTrkTypeName,
            // cx: item.trkTypeName,
            zzt: '333',
            trkTonnage: item.trkTonnage,
            sj: item.wdcDvrId + '',
            lxdh: item.drvCtctel,
            sxsj: item.wdcStatus === 'Y' ? '时间未给出' : '',
            zt: item.wztzStatus ? '运输中' : '空闲',
            wcdDwt: '',
            wabCtrNo: '', //箱号
            wabSealNo: '', //铅封号
            wabProBatch: '', //生产批次
            gdsWeight: this.sumGdsWeight, //总重量
            isSelect: true,
            terminalNo: item.terminalNo,
          }
        })
        // this.carInfo.forEach((item, index) => {
        //     this.carInfo[index]['sj'] = item.wdcDvrId
        //   })
      })
    },
    // 获取主页上方表格  当前行数据
    getTopCurrent(row) {
      this.topCurrentData = row
      // getWabActivitesSer({
      //   wabUuid: this.topCurrentData.uuid
      // }).then(res => {
      //   this.botTableData = res.data
      // })
    },
    //撤销运单
    undoWayBill() {
      if (Object.keys(this.topCurrentData).length == 0) {
        this.$alert('请选择一条数据', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      if (this.topCurrentData.wabStatus != 'DSH') {
        this.$alert('已接单后的运单不可撤销！', '提示', {
          confirmButtonText: '确定',
        })
        return
      }
      this.topCurrentData.WAB_WEIGHT = this.topCurrentData.wabWeight
      this.$confirm('是否确认撤销?', '提示', {
        closeOnClickModal: false,
      }).then(() => {
        undoWayBill({
          waybill: this.topCurrentData,
        })
          .then(() => {
            this.$message.success('撤销运单成功！')
          })
          .finally(() => {
            this.topCurrentData = {}
            this.topTableData = []
            this.searchList()
          })
      })
    },
    cellStyleHandler({ row, column, rowIndex, columnIndex }) {
      row.rowIndex = rowIndex
      column.columnIndex = columnIndex
    },
    // 粘贴excel复制的数据到表格中
    onPaste({ row, column }, e) {
      let data = null
      let clipboardData = e.clipboardData // IE
      if (!clipboardData) {
        //chrome
        clipboardData = e.originalEvent.clipboardData
      }
      data = clipboardData.getData('Text')
      if (!data.length) {
        return
      }
      let delimiter = '\n'
      if (data.indexOf('\r\n')) {
        delimiter = '\r\n'
      }
      let rowStrArray = data.split(delimiter)
      // 粘贴的二维数组
      let columnIndex = Number(column.columnIndex)
      const originalColumnIndex = columnIndex
      let rowIndex = Number(row.rowIndex)
      // 特殊处理一下第一个元素
      let firstColumn = originalColumnIndex
      let firstRow = rowIndex
      let firstData = ''
      for (let i = 0; i < rowStrArray.length; i++) {
        let tdStrArray = rowStrArray[i].split('\t')
        for (let j = 0; j < tdStrArray.length; j++) {
          const currentData = tdStrArray[j]
          if (i === 0 && j === 0) {
            firstData = currentData
          }
          const row = this.carInfo[rowIndex]
          switch (columnIndex) {
            case 2:
              row['wabCtrNo'] = currentData
              break
            case 3:
              row['wabSealNo'] = currentData
              break
            case 4:
              row['wabProBatch'] = currentData
              break
            case 5:
              row['wcdDwt'] = currentData
              break
          }
          if (j === tdStrArray.length - 1) {
            columnIndex = originalColumnIndex
          } else {
            columnIndex++
          }
        }
        rowIndex++
      }
      if (firstData !== '') {
        const _t = this
        setTimeout(() => {
          _t.$nextTick(() => {
            const row = this.carInfo[firstRow]
            switch (firstColumn) {
              case 2:
                row['wabCtrNo'] = firstData
                break
              case 3:
                row['wabSealNo'] = firstData
                break
              case 4:
                row['wabProBatch'] = firstData
                break
              case 5:
                row['wcdDwt'] = firstData
                break
            }
          })
        }, 200)
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.step2-upload {
  width: 100%;
  height: 100px;
  background-color: #efefef;
  margin-top: 10px;
  position: relative;
  p {
    position: absolute;
    top: 120px;
    left: 22px;
  }
  i {
    position: absolute;
    top: 42%;
    left: 42%;
  }
  img {
    width: 100%;
    height: 100px;
  }
  .el-upload-list__item-delete {
    position: absolute;
    right: 97px;
    top: 43px;
    font-size: 20px;
    color: #606266;
  }
}
.bottom-code {
  width: 100%;
  height: 100%;

  .bottomBtn {
    margin-top: 3px;
    margin-bottom: 3px;
  }

  .name {
    font-size: 16px;
    line-height: 20px;
    font-weight: 500;
  }
}

.wrapper {
  width: 100%;
  height: 100%;
  padding: 12px 15px;

  .concate {
    display: flex;
    justify-content: space-between;
    // padding:10px 0;
    .send {
      width: 49%;
    }

    .accept {
      width: 49%;
    }
  }

  .box {
    padding: 12px;
    position: relative;
    border: 1px solid rgb(29, 158, 233);
    border-radius: 5px;
    // height:300px;
    margin-bottom: 20px;

    .name {
      position: absolute;
      top: -20px;
      font-size: 16px;
      font-weight: 700;
      padding: 10px;
      line-height: 20px;
      background: #fff;
    }
  }
}

.top-type {
  //  height:500px;
  height: 93%;
  display: flex;
  flex-direction: column;

  .btn {
    height: 50px;
    line-height: 50px;
  }

  .name {
    padding-top: 0px;
    font-size: 16px;
    line-height: 20px;
    font-weight: 500;
  }

  .table {
    flex: 1;
  }

  .pages {
    height: 30px;
  }
}
</style>
